import React, { useCallback, useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'

const ReactReduxHooksPage = props => {
  const count = useSelector(({count}) => count) // 子组件可以通过useSelector 访问state
  const dispatch = useDispatch() // 子组件可以通过useDispatch 访问dispatch
  const add = useCallback(() => {
    dispatch({type: "ADD"});
  }, []);
  return (
    <>
      <h3>ReactReductHooks</h3>
      <p>{count}</p>
      <button onClick={add}>add</button>
      
    </>
  )
}
export default ReactReduxHooksPage